package com.hhkj.admin.course.controller;

import com.hhkj.admin.course.domain.Course;
import com.hhkj.admin.course.model.req.CourseReq;
import com.hhkj.admin.course.model.req.CourseShowHiddenReq;
import com.hhkj.admin.course.model.res.CourseRes;
import com.hhkj.admin.course.service.biz.CourseBizService;
import com.ruoyi.common.annotation.LogTitlePrefix;
import com.ruoyi.common.annotation.PermissionPrefix;
import com.ruoyi.common.base.biz.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 课程信息Controller
 *
 * @author ruoyi
 * @since 2023-05-09
 */
@LogTitlePrefix("课程信息")
@PermissionPrefix("train:course")
@RestController
@RequestMapping("/course")
public class CourseController extends BaseController<Course, CourseReq, CourseRes, CourseBizService> {
    /** 查询课程信息树型列表 */
    @GetMapping("/all/tree/list")
    public TableDataInfo listTreeAll() {
        return getDataTable(this.getBizService().listTreeAll(true, true));
    }

    /** 查询课程信息列表 */
    @PostMapping("/list")
    public TableDataInfo list(@RequestBody CourseReq req) {
        List<CourseRes> list = this.getBizService().list(req);
        return getDataTable(list);
    }

    /**
     * 显示/隐藏课程
     * @param req
     * @return
     */
    @PutMapping("/hidden/flag")
    public AjaxResult hiddenShowCourse(@Validated @RequestBody CourseShowHiddenReq req)
    {
        return toAjax(this.getBizService().hiddenShowCourse(req));
    }
}
